﻿$("#exampleAccordion>li:nth-child(1)").addClass("active");
$(function () {
    if ($("#myAreaChart").length > 0) {
        var columns = [{ "data": "DataStr" }, { "data": "Type" }, { "data": "Money" }, { "data": "AddDT" }, { "data": "DataDT", render: function (value, type, row) { return '<a href="javascript:void(0)" onclick="detailsView(&apos;' + row.Id + '&apos;)">查看明细</a>' } },]
        dataTable.dataTables("/Index/GetMonthData", columns, false);
        $("#dataTable_wrapper .row:last-child").addClass("mt-2");
        var optionArea = {
            url: "/Index/GetLineData",
            type: "post",
            callback: function (data) {
                Charts.lineChart(data.Labels, data.Data, "myAreaChart");
            }
        }
        swGather.swAjax(optionArea);
    }
    var optionPie = {
        url: "/Index/GetPie",
        type: "post",
        callback: function (data) {
            Charts.PieChart(data.Lables, data.Data, "myPieChart");
            $("#PieChart .card-header span").text(data.Msg)
        }
    }
    swGather.swAjax(optionPie)
    $('#dataTableMsg').DataTable({
        "bFilter": false,
        "oLanguage": { //国际化配置
            "sProcessing": "正在获取数据，请稍后...",
            "sLengthMenu": "显示 _MENU_ 条",
            "sZeroRecords": "没有您要的内容",
            "sInfo": "从 _START_ 到  _END_ 条 总共 _TOTAL_ 条",
            "sInfoEmpty": "记录数为0",
            "sInfoFiltered": "(全部记录数 _MAX_ 条)",
            "sInfoPostFix": "",
            "sSearch": "搜索",
            "sUrl": "",
            "oPaginate": {
                "sFirst": "第一页",
                "sPrevious": "上一页",
                "sNext": "下一页",
                "sLast": "最后一页"
            }
        }
    });
})
function detailsView(data) {
    var year, month;
    year = data.split(",")[0];
    month = data.split(",")[1];
    $.post("/Index/GetOneMonth", { month: month, year: year }, function (data) {
        $('#myAreaChart').fadeOut({
            duration: 1000,
            easing: 'easeOutSine',
            complete:function() {
                $(this).remove();
                $('#AreaChart .card-header span').text(data.Msg + "月份详细财务报表")
                $('#AreaChart .card-body').append('<canvas id="myAreaChart" height="100"></canvas>');
                Charts.lineChart(data.Labels, data.Data, "myAreaChart");
            }
        });
    })
}